package com.crm.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import com.crm.interceptor.LoginInterceptor;



@Configuration
public class WebConfig implements WebMvcConfigurer {
	
	@Autowired
	private LoginInterceptor loginInterceptor;
	
	@Override
	public void addInterceptors(InterceptorRegistry registry) {
		//注入拦截器
		registry.addInterceptor(loginInterceptor)
		//addPathPatterns("/**")拦截所有
		//excludePathPatterns("/....")放形路径
			.addPathPatterns("/**").excludePathPatterns("/login","/login/getVerify"
						,"/login/checkVerify","/login/login","/user/getUserModule","/excel/stuout","/excel/stuin"
						,"/message/**","/websocket/**","/user/allUserName","/user/findId/jiancha","/user/forgetPwd"
						,"/demo");
	}

	
	@Override
	public void addCorsMappings(CorsRegistry registry) {
		
		registry.addMapping("/**").allowedMethods("POST","DELETE","PUT","GET");
	}
	
	
}
